<template>
  <view class="device-bound-container">
    <!-- 状态栏占位 -->
    <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
    
    <!-- 顶部导航栏 -->
    <view class="bound-navbar">
      <view class="navbar-content">
        <view class="nav-left" @click="goBack">
          <text class="back-icon">‹</text>
        </view>
        <text class="nav-title">已绑定设备</text>
        <view class="nav-right">
          <view class="nav-action-btn">
            <text class="action-dots">⋯</text>
          </view>
          <view class="nav-action-btn">
            <text class="action-location">📍</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content-area">
      <!-- 已绑定设备标题 -->
      <view class="section-header">
        <text class="section-title">已绑定设备</text>
        <view class="action-link" @click="researchDevice">
          <text class="link-text">重新查找</text>
        </view>
      </view>

      <!-- 设备列表 -->
      <view class="device-list">
        <view class="device-item">
          <view class="device-icon">
            <view class="device-image">📱</view>
          </view>
          <view class="device-details">
            <text class="device-name">某品牌型号听诊宝</text>
            <view class="device-actions">
              <view class="action-tag connected">
                <text class="tag-text">已连接</text>
              </view>
              <view class="action-link">
                <text class="link-text">解绑</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      statusBarHeight: 0,
      deviceType: ''
    }
  },
  
  onLoad(options) {
    this.getSystemInfo()
    this.deviceType = options.deviceType || 'stethoscope'
  },
  
  methods: {
    getSystemInfo() {
      const systemInfo = uni.getSystemInfoSync()
      this.statusBarHeight = systemInfo.statusBarHeight || 0
    },
    
    goBack() {
      uni.navigateBack()
    },
    
    researchDevice() {
      uni.navigateTo({
        url: `/pages/startPairing/index?deviceType=${this.deviceType}`
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.device-bound-container {
  min-height: 100vh;
  background: #F5F5F5;
  position: relative;
}

.status-bar {
  background: #FFFFFF;
}

.bound-navbar {
  background: #FFFFFF;
  height: 88rpx;
  border-bottom: 1px solid #E5E5E5;
  
  .navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 32rpx;
    
    .nav-left {
      width: 60rpx;
      height: 60rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      
      .back-icon {
        font-size: 48rpx;
        color: #333333;
        font-weight: bold;
      }
    }
    
    .nav-title {
      font-size: 36rpx;
      font-weight: bold;
      color: #333333;
    }
    
    .nav-right {
      display: flex;
      align-items: center;
      
      .nav-action-btn {
        width: 60rpx;
        height: 60rpx;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 16rpx;
        
        .action-dots, .action-location {
          font-size: 24rpx;
          color: #666666;
        }
      }
    }
  }
}

.content-area {
  padding: 32rpx;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32rpx;
  
  .section-title {
    font-size: 32rpx;
    font-weight: bold;
    color: #333333;
  }
  
  .action-link {
    .link-text {
      font-size: 28rpx;
      color: #2196F3;
      text-decoration: underline;
    }
  }
}

.device-list {
  .device-item {
    background: #FFFFFF;
    border-radius: 16rpx;
    padding: 24rpx;
    margin-bottom: 24rpx;
    box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    
    .device-icon {
      width: 120rpx;
      height: 120rpx;
      margin-right: 24rpx;
      
      .device-image {
        width: 100%;
        height: 100%;
        background: #F5F5F5;
        border-radius: 12rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 48rpx;
      }
    }
    
    .device-details {
      flex: 1;
      
      .device-name {
        font-size: 32rpx;
        font-weight: bold;
        color: #333333;
        display: block;
        margin-bottom: 16rpx;
      }
      
      .device-actions {
        display: flex;
        align-items: center;
        gap: 16rpx;
        
        .action-tag {
          padding: 8rpx 16rpx;
          border-radius: 20rpx;
          
          &.connected {
            background: rgba(76, 175, 80, 0.1);
            
            .tag-text {
              font-size: 24rpx;
              color: #4CAF50;
            }
          }
        }
        
        .action-link {
          .link-text {
            font-size: 28rpx;
            color: #2196F3;
            text-decoration: underline;
          }
        }
      }
    }
  }
}
</style> 